package com.tanhua.dubbo.api.impl;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.tanhua.domain.db.Topic;
import com.tanhua.dubbo.api.TopicApi;
import com.tanhua.dubbo.mapper.TopicMapper;
import org.apache.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

@Service
public class TopicApiImpl implements TopicApi {

    @Autowired
    private TopicMapper topicMapper;

    @Override
    public Topic findById(Integer topicId) {
        return topicMapper.selectById(topicId);
    }

    @Override
    public List<Topic> findByAll() {
        return topicMapper.selectList(null);
    }

    @Override
    public List<Topic> findLevel(Long id) {
        QueryWrapper<Topic> wrapper = new QueryWrapper<>();
        wrapper.eq("questionnaire_id",id);
        return topicMapper.selectList(wrapper);
    }
}
